﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LevelButton : MonoBehaviour
{
	public int level;
	public Image iButton;
	public Image flag;

	void Start ()
	{
		// init button , bat flag neu level da choi qua
		if (level < GameManager.dataSave.levelMax) {
			iButton.sprite = GameDefine.instance.sprLevelButtonOpen;
			if (level == 7 || level == 15) {
				iButton.sprite = GameDefine.instance.sprLevelButtonBossOpen;
			}
			flag.gameObject.SetActive (true);
		} else if (level == GameManager.dataSave.levelMax) {
			iButton.sprite = GameDefine.instance.sprLevelButtonOpen;
			if (level == 7 || level == 15) {
				iButton.sprite = GameDefine.instance.sprLevelButtonBossOpen;
			}
			flag.gameObject.SetActive (false);
		} else {
			iButton.sprite = GameDefine.instance.sprLevelButtonLock;
			if (level == 7 || level == 15) {
				iButton.sprite = GameDefine.instance.sprLevelButtonBossLock;
			}
			flag.gameObject.SetActive (false);
		}
	}

	public void Click ()
	{
		// 
		if (level <= GameManager.dataSave.levelMax) {
			GameManager.currentLevel = level;
			LoadSceneFading.LoadScene ("scn_play");
		}
	}
}
